
load("smalldata.RData")

library(survival)
thesurv = Surv(datamatSmall$Age, datamatSmall$thisEventTime,datamatSmall$thisEventType)


library(INLA)

install.packages("inlaDevel", repos="http://R-Forge.R-project.org")
library(inlaDevel)

forInla = SurvToInla(thesurv)


theformula =  forInla ~ geno*env+  Gender + f(CensusDivision, model="iid",param=c(.11,.011))


# exponential, this works well

res = inla(theformula, data=datamatSmall, family="exponential", 
  working.directory=paste(getwd(),"/", "inla", sep=""),
  control.fixed=list(prec=0.01, prec.intercept=0.0001, mean=0)
  )
res$summary.fixed

# weibull, still trying to get this to work


res = inla(theformula, data=datamatSmall, family="weibull", 
  working.directory=paste(getwd(),"/", "inla", sep=""),
  control.fixed=list(prec=0.01, prec.intercept=0.0001, mean=0),
  control.data=list(initial=log(1.1),param=c(0.012, 0.12) ))

formula=time~age+sex+dis1+dis2+dis3+f(ID, param=c(10^(-4), 10^(-4)))

model=inla.surv(formula, family="weibull", data=Kidney,event=event,
control.fixed=list(prec=10^(-5)),
control.data=list(initial=0.2, param=c(1, 10^(-4))))

